﻿using System;
using System.Linq;
using Solution.BusinessObject;

namespace Solution.Controls
{
    public partial class AlbumsOfAuthor : System.Web.UI.UserControl
    {
        private int _albumId;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["abl"] != null)
            {
                _albumId = Convert.ToInt32(Request["abl"]);
            }

            if (_albumId <= 0)
            {
                return;
            }

            var album = CommonBO.MasterEDM.Contents
                .FirstOrDefault(t => t.Id == _albumId);

            if (album == null)
            {
                return;
            }

            var albums = CommonBO.MasterEDM.Contents
                .Where(t => t.Author.Id == album.Author.Id && t.Id != _albumId)
                .Take(Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["NumberOfTopItem"]))
                .ToList();
            rptAlbums.DataSource = albums;
            rptAlbums.DataBind();
        }
    }
}